package ga.util;

/**
 * Array utilities.
 *
 * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
 * @version 1.0.0.1, Mar 17, 2010
 */
final public class ArrayGenerator {

    private ArrayGenerator() {
    }

    public static final int[] gen(final int[] array1, final int[] array2) {
        int[] ret = new int[array1.length];

        final int separator = (int) (Math.random() * array1.length);

        System.arraycopy(array1, 0, ret, 0, separator);
        System.arraycopy(array2, separator, ret, separator, array1.length
                                                            - separator);

        return ret;
    }

    public static final void swap(final int[] array, final int i, final int j) {
        final int tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }
}
